package com.xiaoq.system.repository.impl;

import org.mongodb.morphia.Datastore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.xiaoq.coms.util.IdGenerator;
import com.xiaoq.system.entity.FeedbackEntity;
import com.xiaoq.system.repository.IFeedbackRepository;
@Repository
public class FeedbackRepositoryImpl implements IFeedbackRepository {
	
	@Autowired
	private Datastore datastore;
	
	@Autowired
	private IdGenerator idGenerator;
	
	private static final Logger LOG = LoggerFactory.getLogger(FeedbackRepositoryImpl.class);

	@Override
	public boolean addFeedback(FeedbackEntity feedback) {
		if(feedback!=null){
			String id = idGenerator.nextId();
			feedback.setId(id);
			LOG.info("插入反馈信息的Id:"+id);
			datastore.save(feedback);
			return true;
		}else{
			LOG.debug("反馈信息不能为空！");
		}
		return false;
	}

}
